<template>
 <a-spin :spinning="confirmLoading">
      <!-- 主表单区域 -->
      <a-form-model ref="form" :model="model" :rules="validatorRules">
        <a-row>
          <a-col :xs="24" :sm="12">
            <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="no" label="入库单号">
              <a-input placeholder="请输入入库单号" v-model="model.no"/>
            </a-form-model-item>
          </a-col>
          <a-col :xs="24" :sm="12">
            <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="adjustNo" label="调整单号">
              <a-input placeholder="请输入调整单号" v-model="model.adjustNo"/>
            </a-form-model-item>
          </a-col>
        </a-row>
        <a-row>
          <a-col :xs="24" :sm="12">
            <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="sourceBase" label="基地">
              <a-input placeholder="请输入基地" v-model="model.sourceBase"/>
            </a-form-model-item>
          </a-col>
          <a-col :xs="24" :sm="12">
            <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="sourceGreenhouse" label="地块">
              <a-input placeholder="请输入地块" v-model="model.sourceGreenhouse"/>
            </a-form-model-item>
          </a-col>
        </a-row>
        <a-row>
          <a-col :xs="24" :sm="12">
            <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="storehouse" label="库房">
              <a-input placeholder="请输入库房" v-model="model.storehouse"/>
            </a-form-model-item>
          </a-col>
          <a-col :xs="24" :sm="12">
            <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="cost" label="成本中心">
              <a-input placeholder="请输入成本中心" v-model="model.cost"/>
            </a-form-model-item>
          </a-col>
        </a-row>
        <a-row>
          <a-col :xs="24" :sm="12">
            <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="sortTime" label="分拣日期">
              <a-date-picker placeholder="请输入分拣日期" style="width:100%" :showTime="true" valueFormat="YYYY-MM-DD HH:mm:ss" v-model="model.sortTime"/>
            </a-form-model-item>
          </a-col>
          <a-col :xs="24" :sm="12">
            <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="period" label="账期号">
              <a-input placeholder="请输入账期号" v-model="model.period"/>
            </a-form-model-item>
          </a-col>
        </a-row>
        <a-row>
          <a-col :xs="24" :sm="12">
            <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="periodState" label="账期状态">
              <a-input placeholder="请输入账期状态" v-model="model.periodState"/>
            </a-form-model-item>
          </a-col>
          <a-col :xs="24" :sm="12">
            <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="financeSureUser" label="财务确认人">
              <a-input placeholder="请输入财务确认人" v-model="model.financeSureUser"/>
            </a-form-model-item>
          </a-col>
        </a-row>
        <a-row>
          <a-col :xs="24" :sm="12">
            <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="financeSureTime" label="财务确认时间">
              <a-date-picker placeholder="请输入财务确认时间" style="width:100%" :showTime="true" valueFormat="YYYY-MM-DD HH:mm:ss" v-model="model.financeSureTime"/>
            </a-form-model-item>
          </a-col>
          <a-col :xs="24" :sm="12">
            <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="storekeeperSureUser" label="库管确认人">
              <a-input placeholder="请输入库管确认人" v-model="model.storekeeperSureUser"/>
            </a-form-model-item>
          </a-col>
        </a-row>
        <a-row>
          <a-col :xs="24" :sm="12">
            <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="storekeeperSureTime" label="库管确认时间">
              <a-date-picker placeholder="请输入库管确认时间" style="width:100%" :showTime="true" valueFormat="YYYY-MM-DD HH:mm:ss" v-model="model.storekeeperSureTime"/>
            </a-form-model-item>
          </a-col>
          <a-col :xs="24" :sm="12">
            <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="operationSureUser" label="运管确认人">
              <a-input placeholder="请输入运管确认人" v-model="model.operationSureUser"/>
            </a-form-model-item>
          </a-col>
        </a-row>
        <a-row>
          <a-col :xs="24" :sm="12">
            <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="operationSureTime" label="运管确认时间">
              <a-date-picker placeholder="请输入运管确认时间" style="width:100%" :showTime="true" valueFormat="YYYY-MM-DD HH:mm:ss" v-model="model.operationSureTime"/>
            </a-form-model-item>
          </a-col>
          <a-col :xs="24" :sm="12">
            <a-form-model-item :labelCol="labelCol" :wrapperCol="wrapperCol" prop="state" label="状态（0录入，1财务确认，2库管确认，3运管确认）">
              <a-input-number placeholder="请输入状态（0录入，1财务确认，2库管确认，3运管确认）" style="width:100%" v-model="model.state"/>
            </a-form-model-item>
          </a-col>
        </a-row>
      </a-form-model>

      <!-- 子表单区域 -->
      <a-tabs v-model="activeKey" @change="handleChangeTabs">
        <a-tab-pane tab="批量入库调整子表" :key="refKeys[0]" :forceRender="true">
          <j-editable-table
            :ref="refKeys[0]"
            :loading="tFlowerAdjustTagInTable.loading"
            :columns="tFlowerAdjustTagInTable.columns"
            :dataSource="tFlowerAdjustTagInTable.dataSource"
            :maxHeight="300"
            :rowNumber="true"
            :rowSelection="true"
            :actionButton="true"/>
        </a-tab-pane>
      </a-tabs>
    </a-spin>
</template>

<script>

    import { FormTypes } from '@/utils/JEditableTableUtil'
    import { JEditableTableModelMixin } from '@/mixins/JEditableTableModelMixin'

    export default {
      name: 'TFlowerAdjustTagInMainForm',
      mixins: [JEditableTableModelMixin],
      data() {
        return {
          // 新增时子表默认添加几行空数据
          addDefaultRowNum: 1,
          model: {
          //设置默认值
           },
          validatorRules: {
            storehouse: [{ required: true, message: '请输入库房!' }],
            periodState: [{ required: true, message: '请输入账期状态!' }],
          },
          refKeys: ['tFlowerAdjustTagIn', ],
          activeKey: 'tFlowerAdjustTagIn',
          // 批量入库调整子表
          tFlowerAdjustTagInTable: {
            loading: false,
            dataSource: [],
            columns: [
              {
                title: '编号',
                key: 'no',
                type: FormTypes.inputNumber,
                defaultValue: '',
                placeholder: '请输入${title}',
                validateRules: [{ required: true, message: '${title}不能为空' }],
              },
              {
                title: '主表id',
                key: 'mainid',
                type: FormTypes.input,
                defaultValue: '',
                placeholder: '请输入${title}',
              },
              {
                title: '基地',
                key: 'sourceBase',
                type: FormTypes.input,
                defaultValue: '',
                placeholder: '请输入${title}',
              },
              {
                title: '地块',
                key: 'sourceGreenhouse',
                type: FormTypes.input,
                defaultValue: '',
                placeholder: '请输入${title}',
              },
              {
                title: '采收产品',
                key: 'variety',
                type: FormTypes.input,
                defaultValue: '',
                placeholder: '请输入${title}',
                validateRules: [{ required: true, message: '${title}不能为空' }],
              },
              {
                title: '产品编码',
                key: 'varietyCode',
                type: FormTypes.input,
                defaultValue: '',
                placeholder: '请输入${title}',
                validateRules: [{ required: true, message: '${title}不能为空' }],
              },
              {
                title: '分拣日期',
                key: 'sortTime',
                type: FormTypes.datetime,
                defaultValue: '',
                placeholder: '请输入${title}',
              },
              {
                title: '打包规格',
                key: 'packingSpecifications',
                type: FormTypes.input,
                defaultValue: '',
                placeholder: '请输入${title}',
                validateRules: [{ required: true, message: '${title}不能为空' }],
              },
              {
                title: '等级',
                key: 'classes',
                type: FormTypes.input,
                defaultValue: '',
                placeholder: '请输入${title}',
              },
              {
                title: '入库数量',
                key: 'tagNum',
                type: FormTypes.inputNumber,
                defaultValue: '',
                placeholder: '请输入${title}',
                validateRules: [{ required: true, message: '${title}不能为空' }],
              },
              {
                title: '单位',
                key: 'flowerPoleLength',
                type: FormTypes.input,
                defaultValue: '',
                placeholder: '请输入${title}',
                validateRules: [{ required: true, message: '${title}不能为空' }],
              },
              {
                title: '库房',
                key: 'storehouse',
                type: FormTypes.input,
                defaultValue: '',
                placeholder: '请输入${title}',
                validateRules: [{ required: true, message: '${title}不能为空' }],
              },
              {
                title: '成本中心',
                key: 'cost',
                type: FormTypes.input,
                defaultValue: '',
                placeholder: '请输入${title}',
              },
              {
                title: '创建人',
                key: 'createUser',
                type: FormTypes.input,
                defaultValue: '',
                placeholder: '请输入${title}',
              },
              {
                title: '更新人',
                key: 'updateUser',
                type: FormTypes.input,
                defaultValue: '',
                placeholder: '请输入${title}',
              },
              {
                title: '状态（0正常，1删除）',
                key: 'state',
                type: FormTypes.input,
                defaultValue: '',
                placeholder: '请输入${title}',
              },
              {
                title: '打印标签次数（0未打印，1打印，）',
                key: 'printNum',
                type: FormTypes.inputNumber,
                defaultValue: '',
                placeholder: '请输入${title}',
              },
            ]
          },
          url: {
            add: "/flower/tFlowerAdjustTagInMain/add",
            edit: "/flower/tFlowerAdjustTagInMain/edit",
            tFlowerAdjustTagIn: {
              list: '/flower/tFlowerAdjustTagInMain/queryTFlowerAdjustTagInByMainId'
            },
          }
        }
      },
      methods: {
        /** 调用完edit()方法之后会自动调用此方法 */
        editAfter() {
          // 加载子表数据
          if (this.model.id) {
            let params = { id: this.model.id }
            this.requestSubTableData(this.url.tFlowerAdjustTagIn.list, params, this.tFlowerAdjustTagInTable)
          }
        },

        /** 整理成formData */
        classifyIntoFormData(allValues) {
          let main = Object.assign(this.model, allValues.formValue)
          return {
            ...main, // 展开
            tFlowerAdjustTagInList: allValues.tablesValue[0].values,
          }
        }
      }
    }
</script>

<style scoped>
</style>